Workflow Loop Template
The Workflow Loop template demonstrates how a workflow can repeat a sequence of nodes until a specified condition becomes false. Instead of duplicating workflow steps, a Loop node repeatedly executes the same workflow branch while updating the workflow context after each iteration. This template introduces iterative execution into BindAI workflows.Purpose
This template demonstrates how to:- repeat workflow execution
- evaluate a loop predicate
- update workflow variables
- exit the loop safely
- build iterative automation
Workflow Structure
A loop creates a cycle in the workflow.Execution Flow
Each iteration follows the same sequence.False.
Loop Predicate
The Loop node evaluates a predicate before each iteration. Conceptually:- True → execute another iteration
- False → continue to the workflow exit
Workflow Variables
Loops usually depend on workflow variables. Example:Example
Suppose an AI agent processes one item per iteration.Shared Context
Every iteration shares the same workflow context.Loop Exit
Eventually the predicate evaluates to false.Polling Example
Loops are useful when waiting for an external process.Batch Processing
A common use case is processing collections.Loop vs Retry
Although they both involve repeated execution, loops and retries solve different problems.
Retries recover from temporary failures.
Loops intentionally repeat workflow logic.
Preventing Infinite Loops
Every loop should eventually terminate. A good pattern is:Related Templates
This template prepares you for:- Workflow Parallel
- Workflow Human
- Workflow Retry
- Workflow Timeout
Best Practices
- Always define a clear exit condition.
- Update workflow variables during each iteration.
- Keep loop bodies focused on one responsibility.
- Avoid deeply nested loops.
- Use retries instead of loops for transient failures.
- Monitor long-running loops in production.
